package cn.keniykey.mc.landterritory.landflag.api;

import java.util.HashMap;

import javax.annotation.Nullable;

import cn.keniykey.mc.landterritory.landflag.LandFlag;

public final class LandFlagSetting {
	private LandFlagSetting() {}
	
	private static HashMap<String,ILandFlagAuthority> hashmap_land_authoritys = new HashMap<>();
	private static HashMap<String,ILandFlagAuthority> hashmap_flag_authoritys = new HashMap<>();
	private static HashMap<String,ILandFlagDetection> hashmap_add_detection = new HashMap<>();
	private static HashMap<String,ILandFlagDetection> hashmap_remove_detection = new HashMap<>();
	private static HashMap<String,ILandFlagDetection> hashmap_click_detection = new HashMap<>();
	private static HashMap<String,ILandFlagDetection> hashmap_update_detection = new HashMap<>();
	
	public static void reset() {
		hashmap_land_authoritys.clear();
		hashmap_flag_authoritys.clear();
		hashmap_add_detection.clear();
		hashmap_remove_detection.clear();
		hashmap_click_detection.clear();
		hashmap_update_detection.clear();
	}
	public static void reset(String name) {
		hashmap_land_authoritys.remove(name);
		hashmap_flag_authoritys.remove(name);
		hashmap_add_detection.remove(name);
		hashmap_remove_detection.remove(name);
		hashmap_click_detection.remove(name);
		hashmap_update_detection.remove(name);
	}
	public static void setLandAuthority(LandFlag flag,@Nullable ILandFlagAuthority auth) {
		if(auth == null) {
			hashmap_land_authoritys.remove(flag.getName());
		}else {
			hashmap_land_authoritys.put(flag.getName(), auth);
		}
	}
	@Nullable
	public static ILandFlagAuthority getLandAuthority(String name) {
		return (hashmap_land_authoritys.containsKey(name) ? hashmap_land_authoritys.get(name) : null);
	}
	
	public static void setFlagAuthority(LandFlag flag,@Nullable ILandFlagAuthority auth) {
		if(auth == null) {
			hashmap_flag_authoritys.remove(flag.getName());
		}else {
			hashmap_flag_authoritys.put(flag.getName(), auth);
		}
	}
	@Nullable
	public static ILandFlagAuthority getFlagAuthority(String name) {
		return (hashmap_flag_authoritys.containsKey(name) ? hashmap_flag_authoritys.get(name) : null);
	}
	public static void setAddDetection(LandFlag flag,@Nullable ILandFlagDetection dete) {
		if(dete == null) {
			hashmap_add_detection.remove(flag.getName());
		}else {
			hashmap_add_detection.put(flag.getName(), dete);
		}
	}
	@Nullable
	public static ILandFlagDetection getAddDetection(String name) {
		return (hashmap_add_detection.containsKey(name) ? hashmap_add_detection.get(name) : null);
	}
	public static void setRemoveDetection(LandFlag flag,@Nullable ILandFlagDetection dete) {
		if(dete == null) {
			hashmap_remove_detection.remove(flag.getName());
		}else {
			hashmap_remove_detection.put(flag.getName(), dete);
		}
	}
	@Nullable
	public static ILandFlagDetection getRemoveDetection(String name) {
		return (hashmap_remove_detection.containsKey(name) ? hashmap_remove_detection.get(name) : null);
	}
	public static void setClickDetection(LandFlag flag,@Nullable ILandFlagDetection dete) {
		if(dete == null) {
			hashmap_click_detection.remove(flag.getName());
		}else {
			hashmap_click_detection.put(flag.getName(), dete);
		}
	}
	@Nullable
	public static ILandFlagDetection getClickDetection(String name) {
		return (hashmap_click_detection.containsKey(name) ? hashmap_click_detection.get(name) : null);
	}
	public static void setUpdateDetection(LandFlag flag,@Nullable ILandFlagDetection dete) {
		if(dete == null) {
			hashmap_update_detection.remove(flag.getName());
		}else {
			hashmap_update_detection.put(flag.getName(), dete);
		}
	}
	@Nullable
	public static ILandFlagDetection getUpdateDetection(String name) {
		return (hashmap_update_detection.containsKey(name) ? hashmap_update_detection.get(name) : null);
	}
}